
package com.smth.infobox;

import com.smth.infobox.utils.SecurityUtils;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class CategoryActivity extends ListActivity {
    public static String URL_STRING = "url_string";

    public static String IS_URL = "is_url";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setListAdapter(ArrayAdapter.createFromResource(this, R.array.category,
                android.R.layout.simple_list_item_1));

    }

    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        Intent intent = new Intent(this, Infobox.class);
        intent.putExtra(IS_URL, true);
        String URL = "http://wap.infobox.cn/index_activities.php?";
        switch (position) {
            case 0:
                // intent.putExtra(URL_STRING,
                // "http://m.infobox.cn/index_activities.php?&class_id=6");
                break;
            case 1:
                // intent.putExtra(URL_STRING,
                // "http://m.infobox.cn/index_activities.php?&class_id=5");
                break;
            case 2:
                // intent.putExtra(URL_STRING,
                // "http://m.infobox.cn/index_activities.php?&class_id=3");
                break;
            case 3:
                // intent.putExtra(URL_STRING,
                // "http://m.infobox.cn/index_activities.php?&class_id=4");
                break;
            case 4:
                // intent.putExtra(URL_STRING,
                // "http://m.infobox.cn/index_activities.php?&class_id=1");
                break;
            case 5:
                // intent.putExtra(URL_STRING,
                // "http://m.infobox.cn/index_activities.php?&class_id=2");
                break;
            case 6:
                // intent.putExtra(URL_STRING,
                // "http://m.infobox.cn/index_activities.php?&class_id=7");
                break;
        }
        URL += "user_name=" + Session.getInstance().getUserName() + "&user_password="
                + SecurityUtils.toMD5(Session.getInstance().getPassword().getBytes());
        Log.d("Infobox", URL);
        intent.putExtra(URL_STRING, URL);
        startActivity(intent);
    }
}
